﻿using HZU.ZP.Data.Impl;
using HZU.ZP.Data.Interfaces;
using HZU.ZP.Domain.IService;
using HZU.ZP.Domain.Model;
using HZU.ZP.Domain.ServiceImpl.Mappers;
using System;
using System.Collections.Generic;
using System.Text;

namespace HZU.ZP.Domain.ServiceImpl.PCSvc
{
    public class ZanService:IZanService
    {
        private ZanMapper _mapper = new ZanMapper();
        private IZanDao _sqlData;
        public ZanService(IZanDao sqlData)
        {
            _sqlData = sqlData;
        }

        public bool Add(Zan zan)
        {
            var zanDao = _mapper.MapToDao(zan);
            _sqlData.Add(zanDao);
            return true;
        }

        public bool Delete(int id)
        {
            _sqlData.Delete(id);
            return true;
        }

        public Zan GetZan(int noticeId, int userId, string roleName)
        {
            return _mapper.MapToDomain(_sqlData.GetZan(noticeId, userId, roleName));
        }

        public int GetZanCount(int noticeId)
        {
            return _sqlData.GetZanCount(noticeId);
        }
    }
}
